using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace GearBlog.Web.Utils
{
	using System.Collections;

	public class DictUtil
	{
		public static string ObtainEntryAndRemove(IDictionary attributes, string key, string defaultValue)
		{
			string value = ObtainEntryAndRemove(attributes, key);

			return value != null ? value : defaultValue;
		}

		/// <summary>
		/// Obtains the entry and remove it if found.
		/// </summary>
		/// <param name="attributes">The attributes.</param>
		/// <param name="key">The key.</param>
		/// <returns>the entry value or null</returns>
		public static string ObtainEntryAndRemove(IDictionary attributes, string key)
		{
			string value = null;

			if (attributes != null && attributes.Contains(key))
			{
				value = (String)attributes[key];

				attributes.Remove(key);
			}

			return value;
		}
	}
}
